<template>
  <el-dialog title="添加商品类别" :visible.sync="dialogFormVisible">
    <el-form ref="form" :model="form"
             size="mini"
             label-width="5vw">
      <el-form-item label="类别名称" >
        <el-input v-model="form.kind"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <el-button @click="dialogFormVisible=false">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
    import bus from "../../../bus";
    import {addKind} from "../setting/models/kind";

    export default {
        name: "AddKind",
      props:['callBack'],
      data(){
          return{
            dialogFormVisible: false,
            form: {
              kind: '',
            },
          }
      },
      methods:{
          onSubmit(){
            addKind(this.form.kind).then(success=>{
              this.$message({
                message:this.form.kind+'添加成功',
                type:'success'
              })
              //this.$emit('loadKinds')
              this.callBack();
              this.dialogFormVisible=false;
            },failed=>{
              this.$message({
                message:failed.msg,
                type:'warning',
              })
            })
          }

      }
    }
</script>

<style scoped>

</style>
